<template>
	<view class="content upde-info">
		<view class="input-group">
			<view class="input-row border">
				<label class="title">受检单位</label>
				<view class="input-text uni-input uni-view" >{{data.testName}}</view>
			</view>
			<view class="input-row border">
				<label class="title">联系部门</label>
				<view class="input-text uni-view" >{{data.linkOrg||''}}</view>
			</view>
			<view class="input-row border">
				<label class="title">单位地址</label>
				<view class="input-text uni-view" >{{data.address||''}}</view>
			</view>
			<view class="input-row border">
				<label class="title">联系人</label>
				<view class="input-text uni-view" >{{data.linkMan||''}}</view>
			</view>
			<view class="input-row border">
				<label class="title">联系电话</label>
				<view class="input-text uni-view" >{{data.linkPhone||''}}</view>
			</view>

			<view class="input-row border">
				<label class="title">检测地点</label>
				<view class="input-text uni-view" >{{data.testAddress||''}}</view>
			</view>
			<view class="input-row border">
				<label class="title">防雷类别</label>
				<view class="input-text uni-view" >{{data.fltype||''}}</view>
			</view>
			<view class="input-row border">
				<label class="title">状态</label>
				<view class="input-text uni-view" >{{data.stateText}}</view>
			</view>
			<view class="input-row border">
				<label class="title">创建人</label>
				<view class="input-text uni-view" >{{data.createUserName}}</view>
			</view>
			<view class="input-row border">
				<label class="title">创建时间</label>
				<view class="input-text uni-view" >{{data.createTime}}</view>
			</view>
			<view class="input-row ">
			</view>
			<view class="input-row border" v-if="data.state>0">
				<label class="title">审批人</label>
				<view class="input-text uni-view" >{{data.approvlIdName}}</view>
			</view>
			<view class="input-row border" v-if="data.state>0">
				<label class="title">审批备注</label>
				<view class="input-text uni-view" >{{data.remark}}</view>
			</view>
			
			<view class="btn-row" v-if="data.state==1">
				<button type="primary" class="primary" @tap="testing">开始检测</button>
			</view>
			<view class="btn-row" v-if="data.state==2">
				<button type="primary" class="primary" @tap="report">生成报告</button>
			</view>
			<view class="btn-row" v-if="data.state==3 || data.state==4 ||data.state==5 || data.state==6">
				<button type="primary" class="primary" @tap="report">查看报告</button>
			</view>
		</view>
	</view>
</template>


<script>
	import api from '../../api.js';

	export default {
		components: {
		},
		data() {
			return {
				uprefresh:0,
				data:{
					id:0,
					createUser:0,
					testName:'',
					linkOrg:'',
					linkMan:'',
					linkPhone:'',
					address:'',
					testAddress:'',
					fltype:'',
					type:0,
					state:0
				}
			}
		},
		onLoad: function(e) {
			this.id=e.id;
			this.testDetail(e.id)
		},
		onPullDownRefresh() {
			this.uprefresh=1
			this.testDetail(this.id)
		},
		methods: {
			testing(){
				uni.navigateTo({
					url: '/pages/jiance/face?id='+this.data.id
				})
			},
			report(){
				uni.navigateTo({
					url: '/pages/jiance/test?id='+this.data.id+"&url="+encodeURIComponent(api.HOST+"/api/test.do?id="+this.data.id)
				})
			},
			// 修改
			testDetail(id) {
				var that=this
				api.post({
					url: 'api/testDetail.json',
					data: {id:id},
					success(res) {
						if(that.uprefresh==1){
							that.uprefresh=0;
							uni.stopPullDownRefresh();
						}
						if(res.code!=0){
							return uni.showToast({
								icon: 'none',
								title: res.msg,
							});
						}else{
							that.data=res.data;
						}
						
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.upde-info{
		.input-row.border:last-of-type::after{
			height: 0;
		}
		.uni-radio-wrapper{
			.uni-radio-input{
				width: 40upx;
				height: 40upx;
			}
		}
		.picker-item{
			flex: 1;
			.uni-view{
				text-align: left;
			}
		}
	}
	.input-row{		
		.uni-view{
			&.placehold-view{
				color: #808080;
			}
		}
		.radio-group{
			flex: 1;
		}
		.input-text{
			flex: 1;
			min-height: 40upx;
			height: 40upx;
			line-height: 40upx;
			font-size: 28upx;
			padding: 20upx 0;
		}
		.textarea-text {
			flex: 1;
			border: 1px solid #B2B2B2;
			margin: 10upx 10upx 10upx 16upx;
			padding: 10upx;
			font-size: 28upx;
			line-height: 40upx;
			height: 200upx;
		}
	}
	uni-input, uni-input input{
		min-height: 80upx;
	}
	.radio-group {
		height: 40upx;
		.radio{
			margin-right: 20upx;
		}
	}
	
	.img-box-wrapper{
		.img-box {
			width: 160upx;
			height: 160upx;
			position: relative;
			font-size: 0;
			margin: 0 20upx 20upx 0;
			.img {
				width: 160upx;
				height: 160upx;
			}
			.icon-box {
				position: absolute;
				right: 0;
				top: 0;
				transform: translate(50%, -50%);
				background: #fff;
				border-radius: 50%;
				icon {
					float: left;
				}
			}
		}
	}
</style>